package com.cetc32.dh.config;
/**
 * Copyright(C)版权所有 中国电子科技集团公司第三十二研究所
 * @Title: SwaggerCofnig 自动生成接口文档配置类
 * @author: 徐文远
 * @version: 1.0
 * @date: 2020/10/15
 * 备注:无
 */
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * 创建一个api成功工具实例
     * @return Docket
     * **/
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cetc32.dh.controller.rest"))
                .paths(PathSelectors.any()).build();
    }
    /**
     * @return  apiInfo对象
     * */
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("CETC DataManager OpenAPI Doc")
                .description("This is a restful api document of CETC DataManager.")
                .version("1.0")
                .build();
    }

}